package com.phiture.erp.common.utils;

import cn.iocoder.yudao.framework.common.exception.ErrorCode;

import java.util.function.Predicate;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;

public class ValidationUtils {
    private ValidationUtils() {}

    public static  <T> void validateError(T obj, Predicate<T> validator, ErrorCode errorCode){
        if(validator.test(obj)){
            throw exception(errorCode);
        }
    }
}